package com.jic.manager.controller.rest.sys;

import com.jic.common.base.vo.RestResult;
import com.jic.manager.model.entity.SysProtocol;
import com.jic.manager.model.vo.request.SysProtocolRequest;
import com.jic.manager.service.SysProtocolService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Classname AgreementController
 * @Description TODO
 * @Date 2020/11/24 20:15
 * @Created by 22720
 */
@RestController
@Slf4j
@RequestMapping("/sysAgreement")
@Api(tags = " [前端接口]")
public class AgreementController {

    @Resource
    private SysProtocolService service;

    /**
     * 根据协议类型查询信息详情
     * @return
     */
    @PostMapping("/PageList")
    @ApiOperation(value = " 根据协议类型查询信息 ")
    @ResponseBody
    public RestResult<Object> pageList (@RequestBody SysProtocolRequest request) throws Throwable {
        SysProtocol param = new SysProtocol();
        BeanUtils.copyProperties(request, param);
        List<SysProtocol> sysProtocols = service.pageList(param);
        return RestResult.success(sysProtocols);
    }

    /**
     * 根据ID查询信息详情
     */
    @PostMapping("/PageId")
    @ApiOperation(value = " 根据ID查询信息 ")
    @ResponseBody
    public RestResult<SysProtocol> pageId (@RequestBody SysProtocolRequest request) throws Throwable {
        SysProtocol param = new SysProtocol();
        BeanUtils.copyProperties(request, param);
        return RestResult.success(service.pageId(param));
    }

}
